﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace bank
{
    internal class App
    {
        public List<User> users = new List<User>();
        public App() { }

        public void Register()
        {
            Show("----注册新用户----");
            Show("请输入真名:");
            string name = GetInput();
            Show("请输入PIN码:");
            string PIN = GetInput();
            users.Add(new User(name, PIN));
        }

        public void Login()
        {
            Show("----用户登录----");
            Show("请输入真名:");
            string name = GetInput();
            Show("请输入PIN码:");
            string PIN = GetInput();
            User userFind = users.Find(e =>
            {
                if (e.realName == name && e.pin == PIN)
                {
                    return true;
                }
                else
                {
                    return false;
                }
            });

            if(userFind != null)
            {
                Show("登录成功");
            } else
            {
                Show("登录失败");
            }

        }
        private void Show(string message)
        {
            Console.WriteLine(message);
        }
        private string GetInput()
        {
            return Console.ReadLine();
        }
    }
}
